package com.app.coffeephilosophy.activity;


import java.io.File;

import com.app.coffeephilosophy.R;
import com.app.coffeephilosophy.activity.CoffeeMainActivity;
import com.app.coffeephilosophy.activity.CoffeeMakeActivity;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class ImageItemViewActivity extends Activity {
	private ImageView imageView;
	private TextView  itemname;
	private TextView  common;
	private Button  back,analyse,make,share;
	
	/*
	 * 1,fresh 2,warm 3,sad
	 */
	private int type;
	
	private int[] item_fresh = new int[] { R.drawable.kabuqinuo_big,
			R.drawable.lanshan_big, R.drawable.moka_big,
			R.drawable.kabuqinuo_big, R.drawable.kabuqinuo_big,
			R.drawable.kabuqinuo_big, R.drawable.kabuqinuo_big,
			R.drawable.kabuqinuo_big};
	
	private int[] item_warm = new int[] { R.drawable.naicai,
			R.drawable.naicream, R.drawable.naifen,
			R.drawable.naihua, R.drawable.nailao,
			R.drawable.naiqing, R.drawable.naixi,
			R.drawable.naiyou};
	
	private int[] item_sad = new int[] { R.drawable.kabuqinuo_big,
			R.drawable.lanshan_big, R.drawable.moka_big,
			R.drawable.kabuqinuo_big, R.drawable.kabuqinuo_big,
			R.drawable.kabuqinuo_big, R.drawable.kabuqinuo_big,
			R.drawable.kabuqinuo_big};	
	
	 
	public void onCreate(Bundle savedInstanceState) {
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		// 去除标题栏
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.imageitemview);
		findViewById();
		
	    setListener();
	    String[] text_fresh=(String [])this.getResources().getStringArray(R.array.text_fresh);
	    String[] text_warm=(String [])this.getResources().getStringArray(R.array.text_warm);
	    String[] text_sad=(String [])this.getResources().getStringArray(R.array.text_sad);
	    String[] common_fresh=(String [])this.getResources().getStringArray(R.array.common_fresh);
	    String[] common_warm=(String [])this.getResources().getStringArray(R.array.common_warm);
	    String[] common_sad=(String [])this.getResources().getStringArray(R.array.common_sad);
	   
		Intent intent = getIntent();
		int imageId = intent.getIntExtra("id", R.drawable.lanshan_big);
		type = intent.getIntExtra("type", 0);
		switch (type) {		
		case 1:
			
			imageView.setImageResource(item_fresh[imageId]);
		    itemname.setText(text_fresh[imageId]);
	        common.setText(common_fresh[imageId]);
			break;
		case 2:
			imageView.setImageResource(item_warm[imageId]);
			itemname.setText(text_warm[imageId]);
			common.setText(common_warm[imageId]);
			break;
		case 3:
			imageView.setImageResource(item_sad[imageId]);
			itemname.setText(text_sad[imageId]);
			common.setText(common_sad[imageId]);
			break;
		}
	}
	
	public void findViewById(){
		imageView = (ImageView) findViewById(R.id.imageView);
	    itemname =(TextView)findViewById(R.id.itemname);
	    common = (TextView)findViewById(R.id.introduce);
	    back = (Button)findViewById(R.id.itemback);
	    analyse = (Button)findViewById(R.id.analyse);
	    make = (Button)findViewById(R.id.make);
	    share = (Button)findViewById(R.id.share);
		
	}
	
	public void setListener(){
		
		back.setOnClickListener(new OnClickListener(){

			 
			public void onClick(View v) {
				
				Intent intent=new Intent(ImageItemViewActivity.this,CoffeeMainActivity.class);
				startActivity(intent);
				
			}
			
			
		});
		
		analyse.setOnClickListener(new OnClickListener(){

			 
			public void onClick(View v) {
				Intent intent = getIntent();
				int imageId = intent.getIntExtra("id", R.drawable.lanshan_big);
				type = intent.getIntExtra("type", 0);
				intent=new Intent(ImageItemViewActivity.this,CoffeeCharacterActivity.class);
				intent.putExtra("id",imageId);
				intent.putExtra("type", type);
				startActivity(intent);
			}
			
			
		});
		
		make.setOnClickListener(new OnClickListener(){

			 
			public void onClick(View v) {
				Intent intent = getIntent();
				int imageId = intent.getIntExtra("id", R.drawable.lanshan_big);
				type = intent.getIntExtra("type", 0);
				intent=new Intent(ImageItemViewActivity.this,CoffeeMakeActivity.class);
				intent.putExtra("id",imageId);
				intent.putExtra("type", type);
				startActivity(intent);
			}
			
			
		});
		
		share.setOnClickListener(new OnClickListener(){

			 
			public void onClick(View v) {
				
				        Intent intent = getIntent();
						int imageId = intent.getIntExtra("id", R.drawable.lanshan_big);
						type = intent.getIntExtra("type", 0);
						intent.setClass(ImageItemViewActivity.this, WeiboActivity.class);		
						intent.putExtra("imageId",imageId);
						intent.putExtra("type", type);
						startActivity(intent);
				
			}
			
			
		});
		
    
     
	}
	

}
